package de.fhluebeck.oop.gps.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.fhluebeck.oop.gps.dao.IDAO;

/**
 * 
 * Basisklasse für alle DAO Klassen
 * Diese Klasse stellt Basisfunktionalitäten zur Verfügung
 * 
 * 
 * @author Ogün Bilge, Leif Hitzschke
 * @version 1.00, 05.11.2009 
 * @param <T>
 */
public abstract class GenericDAO<T> implements IDAO<T> {
	
	private final static Logger log = LoggerFactory.getLogger(GenericDAO.class);

	protected void close(ResultSet rs) {
		if (rs != null) {
			try {
				rs.close();
				rs = null;
			} catch (SQLException e) {
				log.info("rs close failed");
			}
		}
	}
	protected void close(Statement stmt) {
		if (stmt != null) {
			try {
				stmt.close();
				stmt = null;
			} catch (SQLException e) {
				log.info("stmt close failed");
			}
		}
	}

	protected void close(Connection conn) {
		if (conn != null) {
			try {
				conn.close();
				conn = null;
			} catch (SQLException e) {
				log.info("conn close failed");
			}
		}
	}

}
